﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Models.User;
using WebApplicationBase.Helper;

namespace BLL.User
{
    public class UserService : IUserService
    {
        /// <summary>
        ///     用户登录
        ///     <param name="model">传入用户登录信息model</param>
        /// </summary>
        /// <returns>返回用户登录信息</returns>
        public UserInfo login(LoginUserModel model)
        {
            // 登录成功后进行JWT
            JWTUserInfo jwtUser = new JWTUserInfo { username = model.username, password = model.password, role = "employer" };
            JwtHelper<JWTUserInfo> jwthelper = new JwtHelper<JWTUserInfo>();

            string sJwt = jwthelper.EncodeJwt(jwtUser);

            UserInfo userinfo = new UserInfo { token = sJwt, username = model.username, role = "employer" };

            return userinfo;
        }
    }
}
